package com.bwie.system.controller;

import com.bwie.common.domain.Stu;
import com.bwie.common.result.Result;
import com.bwie.system.service.StuService;
import com.github.pagehelper.PageInfo;
import org.elasticsearch.common.collect.HppcMaps;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("stu")
@CrossOrigin
public class StuController {

    @Autowired
    StuService stuService;
    @PostMapping("stulist")
    public Result stulist(@RequestBody Stu stu){
        PageInfo<Stu> stuPageInfo= stuService.stulist(stu);
        return Result.success(stuPageInfo);
    }
    @DeleteMapping("del")
    public Result del(@PathVariable("stuId") HppcMaps.Object.Integer stuId){
        return null;
    }

    @PutMapping("upd")
    public Result upd(@RequestBody Stu stu){
        int i= stuService.upd(stu);
        if(i>0){
            return Result.success();
        }else{
            return Result.error();
        }
    }
    @PostMapping("add")
    public Result add(@RequestBody Stu stu){
        int i=stuService.add(stu);
        if(i>0){
            return Result.success();
        }
        return Result.error();
    }

}
